
import complex_query from '@dfeidao/atom-nodejs/db/complex-query';
import { IncomingHttpHeaders } from 'http';
import { systemid } from '../../atom/config';


interface Message {
	conference_theme: string;
	start_time: number;
	start_time1: number;
	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}


export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	const query = complex_query(action_id, session_id, systemid);
	if (!message.start_time && !message.start_time1) {
		const res = await query
			// 添加字段
			.add_field('meeting_administration', 'meeting_no', 'meeting_no')
			.add_field('meeting_administration', 'meeting_name', 'meeting_name')
			.add_field('meeting_administration', 'start_time', 'start_time')
			.add_field('meeting_administration', 'conference_theme', 'conference_theme')
			.add_field('meeting_administration', 'meeting_status', 'meeting_status')
			.add_field('meeting_administration', 'sponsor', 'sponsor')
			.add_field('meeting_administration', 'meeting_address', 'meeting_address')
			.where_like('meeting_administration', 'conference_theme', '%' + message.conference_theme + '%')
			// 大于
			// .where_gt('meeting_administration', 'start_time', message.start_time)
			// // 小于
			// .where_lt('meeting_administration', 'start_time', message.start_time1)
			.exec();
		return { res };
	} else {
		const res = await query
			// 添加字段
			.add_field('meeting_administration', 'meeting_no', 'meeting_no')
			.add_field('meeting_administration', 'meeting_name', 'meeting_name')
			.add_field('meeting_administration', 'start_time', 'start_time')
			.add_field('meeting_administration', 'conference_theme', 'conference_theme')
			.add_field('meeting_administration', 'meeting_status', 'meeting_status')
			.add_field('meeting_administration', 'sponsor', 'sponsor')
			.add_field('meeting_administration', 'meeting_address', 'meeting_address')
			.where_like('meeting_administration', 'conference_theme', '%' + message.conference_theme + '%')
			// 大于
			.where_gt('meeting_administration', 'start_time', message.start_time)
			// 小于
			.where_lt('meeting_administration', 'start_time', message.start_time1)
			.exec();
		return { res };
	}


}
